package com.cgwx.commonutils.math.function;

/**
 * @author GaoWei
 * @Date 2021/8/6 - 9:41
 */
public class TanhFunction implements Function
{
    @Override
    public double of(double[] d, int numParam)
    {
        double e = Math.pow(2.718281828459045D, 2.0D * d[0]);
        return (e - 1.0D) / (e + 1.0D);
    }

    @Override
    public boolean acceptNumParam(int numParam)
    {
        return numParam == 1;
    }

    public String toString()
    {
        return "tanh(x)";
    }
}
